#include "stdafx.h"
#include "Sprite.h"
#include "Engine.h"
#include "Effect.h"
#include "VertexTypes.h"
#include "Texture.h"
#include "SpriteInternal.h"

Graphics::Sprite::Sprite()
{
	mySprite = NULL;
}

Graphics::Sprite::~Sprite()
{
	if(mySprite != NULL)
	{
		Syncronization::Syncronizer::Send(Syncronization::MessageSprite::CreateDeleteSprite(mySprite));
	}
}

bool Graphics::Sprite::Init(const std::string& aFileName)
{
	mySprite = new SpriteInternal;
	if(mySprite->Init(aFileName) == false)
	{
		delete mySprite;
		mySprite = NULL;
		return false;
	}

	Syncronization::Syncronizer::Send(Syncronization::MessageSprite::CreateAddSprite(mySprite));

	return true;
}

void Graphics::Sprite::SetPosition(const Vector2f& aPosition)
{
	mySprite->myPosition = aPosition;
}